package 重温_Java并发基础.code.future;

/**
 * @author idea
 * @data 2020/2/15
 */
public class FutureData {

    private RealData realData;

    private boolean isReady=false;

    public synchronized  void setCallableTask(CallableTask callableTask){
        realData=new RealData(callableTask);
        isReady=false;
        notifyAll();
    }

    public synchronized Object get() throws InterruptedException {
        while (!isReady){
            wait();
        }
        return realData.getResult();
    }
}
